package com.front.controller;

import com.front.form.User;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: GetFront
 * Package: com.front.front
 * Description:
 *
 * @Author BuTang
 * @Create 2024/1/5 15:35
 * @Version 1.0
 */
@RestController
@RequestMapping("/")
public class Controller {
    @CrossOrigin("*")
    @GetMapping("/admin/get")
    public String get(){
        String name = "butang";
        System.out.println("butang");
        return name;
    }
    @CrossOrigin("*")
    @GetMapping("get")
    public  User getAjax(){

        System.out.println("获取到了请求");
        return new User("tom","12" );
    }

    @CrossOrigin("*")
    @GetMapping("/getuser")
    public void getuser(@RequestParam("name") String name ,@RequestParam("secret") String secret){
        System.out.println("账户："+ name + '\t' + "密码："+ secret);
    }

    @CrossOrigin("*")
    @PostMapping("/postUser")
    public void postUser(@RequestBody String id ){
        System.out.println(id);
    }


//    @CrossOrigin("*")
//    @PostMapping("/postuser")
//    public void postuser(@RequestBody MultiValueMap<String, String>  formData ){
//        String name = formData.getFirst("name");
//        String secret = formData.getFirst("secret");
//        System.out.println("账户：" + name + '\t' + "密码：" + secret);
////        System.out.println("账户："+ user.name + '\t' + "密码："+ user.secret);
//    }
}
